import 'package:flutter/material.dart';

class CustomRouter extends PageRouteBuilder {
  final Widget widget;
  CustomRouter(this.widget)
      : super(
          transitionDuration: Duration(seconds: 1),
          pageBuilder: (context, animation, secondaryAnimation) {
            return widget;
          },
          transitionsBuilder: (context, animation, secondaryAnimation, child) {
            //渐隐渐现
            // return FadeTransition(
            //     child: child,
            //     opacity: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
            //         parent: animation, curve: Curves.fastOutSlowIn)));

            //缩放
            // return ScaleTransition(
            //   child: child,
            //   scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
            //       parent: animation, curve: Curves.bounceInOut)),
            // );

            //旋转缩放
            // return RotationTransition(
            //     child: ScaleTransition(
            //       child: child,
            //       scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
            //           parent: animation, curve: Curves.fastOutSlowIn)),
            //     ),
            //     turns: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
            //         parent: animation, curve: Curves.fastLinearToSlowEaseIn)));

            //滑动动画
            return SlideTransition(
              child: child,
              position:
                  Tween<Offset>(begin: Offset(-1.0, 0.0), end: Offset(0.0, 0.0))
                      .animate(CurvedAnimation(
                          parent: animation,
                          curve: Curves.fastLinearToSlowEaseIn)),
            );
          },
        );
}
